import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一段字符串:");
        while (scanner.hasNextLine()){
//            System.out.println("请输入一段字符串");
            String str = scanner.nextLine();
            int index = str.lastIndexOf(" ");
            String ret = str.substring(index + 1);
            System.out.println(ret.length());

        }
    }


    //计算字符串最后一个字母的长度，方法一
    public static void main6(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一段字符串:");
        while (scanner.hasNextLine()){
//            System.out.println("请输入一段字符串");
            String str = scanner.nextLine();
            String[] ret = str.split(" ");
            System.out.println(ret[ret.length - 1].length());

        }
    }
    public static void main4(String[] args) {
        String s = "asdfwer";
        System.out.println(s.lastIndexOf("w"));
    }
    public static void main5(String[] args) {
        //方法二
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一串字符串:");
        String str = scanner.nextLine();
        int i = str.lastIndexOf(" ");
        System.out.println(str.length() - 1 - i);


    }
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的名字");
        String name = scanner.nextLine();
        System.out.println("请输入你的年龄");
        int age = scanner.nextInt();
        System.out.println("请输入你的薪资");
        float salary = scanner.nextFloat();
    }
    public static void main1(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        String s = stringBuffer.toString();

        String str = "sdbjv";
//        StringBuffer stringBuffer1 = new StringBuffer(str);
//        System.out.println(stringBuffer1);
        StringBuffer stringBuffer1 = new StringBuffer();
        stringBuffer1.append(str);

    }
}
